package interview.innerClass;

/**
 * 匿名内部类可以继承基类和接口，但是不能通过extends和interface来实现
 */
class Car{
        void move(){}
    }
    interface Person{
        void learn();
    }
    abstract class Animal{
        abstract void eat();
    }
    public class AnonymousInnerClassDemo {
     
        public static void main(String[] args) {
            Car car = new Car(){
                @Override
                void move() {
                    System.out.println("匿名内部类的move方法");
                }
            };
            car.move();
     
            Person person = new Person() {
     
                public void learn() {
                    System.out.println("匿名内部类的learn方法");
                }
            };
            person.learn();
     
            Animal animal = new Animal() {
                @Override
                void eat() {
                    System.out.println("匿名内部类的eat方法");
                }
            };
            animal.eat();
        }
    }